package com.chen.blue.converter.business;

import com.chen.blue.domain.dto.business.ContestApplyActiveDto;
import com.chen.blue.domain.dto.business.update.ContestApplyActiveDtoEdit;
import com.chen.blue.domain.model.business.ContestApplyActiveModel;
import com.chen.blue.domain.vo.business.ContestApplyActiveVo;
import org.springframework.cglib.beans.BeanCopier;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * Created By CLT On 2024/5/23.
 */
@SuppressWarnings("all")
public abstract class ContestApplyActiveConverter {

    private static final BeanCopier modelToVo = BeanCopier.create(ContestApplyActiveModel.class, ContestApplyActiveVo.class, false);
    private static final BeanCopier dtoToModel = BeanCopier.create(ContestApplyActiveDto.class, ContestApplyActiveModel.class, false);
    private static final BeanCopier dtoEditToModel = BeanCopier.create(ContestApplyActiveDtoEdit.class, ContestApplyActiveModel.class, false);

    /**
     * model->vo
     *
     * @param model
     * @return
     */
    public static ContestApplyActiveVo modelToVo(ContestApplyActiveModel model) {
        if (Objects.isNull(model)) {
            return null;
        }
        ContestApplyActiveVo contestApplyActiveVo = new ContestApplyActiveVo();
        modelToVo.copy(model, contestApplyActiveVo, null);
        return contestApplyActiveVo;
    }

    /**
     * model->volist
     *
     * @param modelList
     * @return
     */
    public static List<ContestApplyActiveVo> modelToVoList(List<ContestApplyActiveModel> modelList) {
        if (modelList.size() == 0) {
            return null;
        }

        List<ContestApplyActiveVo> contestApplyActiveVoList = new ArrayList<>();
        for (ContestApplyActiveModel contestApplyActiveModel : modelList) {
            contestApplyActiveVoList.add(modelToVo(contestApplyActiveModel));
        }

        return contestApplyActiveVoList;

    }

    /**
     * dto->model
     *
     * @param postDto
     * @return
     */
    public static ContestApplyActiveModel dtoToModel(ContestApplyActiveDto contestApplyActiveDto) {

        if (Objects.isNull(contestApplyActiveDto)) {
            return null;
        }

        ContestApplyActiveModel contestApplyActiveModel = new ContestApplyActiveModel();
        dtoToModel.copy(contestApplyActiveDto, contestApplyActiveModel, null);
        return contestApplyActiveModel;

    }

    /**
     * editDto->model
     *
     * @param postDtoEdit
     * @return
     */
    public static ContestApplyActiveModel dtoEditToModel(ContestApplyActiveDtoEdit contestApplyActiveDtoEdit) {

        if (Objects.isNull(contestApplyActiveDtoEdit)) {
            return null;
        }

        ContestApplyActiveModel contestApplyActiveModel = new ContestApplyActiveModel();
        dtoEditToModel.copy(contestApplyActiveDtoEdit, contestApplyActiveModel, null);
        return contestApplyActiveModel;

    }

}
